#ifndef IMAGE_H
#define IMAGE_H

#define BLACK	    0x00
#define WHITE	    0xfe
#define TRANSPARENT 0xff

#include <stdint.h>

struct Imageset;

typedef struct {
	char* name;
	uint16_t w, h;
	uint8_t* data;
	struct Imageset* is;
} Image;

#define P(img,x,y) (img)->data[(x)+((y)*(img)->w)]

typedef struct {
	int16_t x, y, w, h;
} Rect;

typedef enum { VERTICAL, HORIZONTAL } Inversion;
typedef enum { CLOCKWISE, ANTICLOCKWISE } Rotation;

Image* image_new(struct Imageset* is, uint16_t w, uint16_t h, char* name);
void image_resize(Image* img, Rect r);
void image_mirror(Image* img, Inversion inv);
void image_rotate(Image* img, Rotation rot);
void image_free(Image* img);

#endif
